<#define __SERVER__="{{LAM.SERVER}}" />
<#define __MODELS__="{{LAM.MODELS}}" />
<#define __COMPONENTS__="{{LAM.COMPONENTS}}" />
#define# __DATA__ <#include repeat="0" tp-data="{}"  file="__SERVER__/sorts/index" /> #end#
#define# __COOKIE__ {{cookie}} #end#


<#define _TITLE_="添加地址" />

<#extends title="_TITLE_" data="{'list':[
{'name':'网页地址','href':'###','title':''},
{'name':'网页地址','href':'###','title':''},
{'name':'_TITLE_'}
]}" />


<#beginBlock id="crumb" data="{'list':[
{'name':'网页地址','href':'###','title':''},
{'name':'网页地址','href':'###','title':''},
{'name':'_TITLE_'}
]}">
<#endBlock>


<#include repeat="0" tp-data="{'cookie':__COOKIE__}"  file="__COMPONENTS__/selectBox.html" />

<form class="form-horizontal" action="__SERVER__/url/add" method="post">
    <div class="sectionWrap-A5">
        <div class="p15">
            <div class="sectionForm-A1 sectionForm-A1-1 sectionForm-A1-1-1 mb15">
                <ul>
                    <li class="clear mb5">
                        <label class="L">类别：<span class="warning">*</span></label>
                        <#=block id="selectBox" data="{'list':__DATA__, 'name':'sid'}" />
                        <span data-error="sid" class="help-block none"></span>
                    </li>
                    <li class="clear mb5">
                        <label class="L">名称：<span class="warning">*</span></label>
                        <input type="text" name="name" class="text name L" value="">
                        <span data-error="name" class="help-block none"></span>
                    </li>

                    <li class="clear mb5">
                        <label class="L">url：<span class="warning">*</span></label>
                        <input type="text" name="url" class="text name L" value="">
                        <span data-error="url" class="help-block none"></span>
                    </li>
                    <li class="textarea clear">
                        <label class="L">简介：<span class="warning">*</span></label>
                        <textarea class="L" name="info"></textarea>
                        <span data-error="info" class="help-block none"></span>
                    </li>
                </ul>
            </div>
            <div class="clear mb10 sectionForm-A1 sectionForm-A1-1-1 sectionForm-A2 ml50">
                <button type="submit" class="btn save L mr15">提交</button>
                <button type="reset" class="btn btn-cancel L">恢复</button>
            </div>
        </div>
    </div>
</form>

<script type="text/javascript">

    LAM.run([jQuery],function($) {
        'use strict';
        var System = this;
        function getByName(name) {
            return document.getElementsByName(name)[0].value;
        }





        $(function(){
            
            $('form').submit(function () {
                var wait = layer.load();
                $('[data-error]').hide();
                var sid  = getByName("sid");
                var name = getByName("name");
                var url  = getByName("url");
                var info = getByName("info");

                

                $[this.method](this.action,{
                    'sid':sid,
                    'name':name,
                    'url':url,
                    'info':info
                },function(data){
                    layer.close(wait);
                    if(data.status){
                        alert(data.message);
                        System.redirect(System.INDEX+"url/index");
                    }else{
                        // alert(data.message);
                        System.each(data.errors,function (key,value) {
                            $('[data-error="'+key+'"]').text(value).show();
                        });
                    }
                },'json');

                return false;
            });



        });
    });
</script>